//
//  NewVideoPostsViewController.swift
//  OnceNectar
//
//  Created by 法正磊 on 2018/2/9.
//  Copyright © 2018年 com.inwhoop. All rights reserved.
//

import UIKit
import TZImagePickerController
import IQKeyboardManagerSwift
class NewVideoPostsViewController: UIViewController, UITextFieldDelegate, AddCornerUIRectCorner, BottomShadow {
    @IBOutlet var shadowViews: [UIView]!
    @IBOutlet weak var circleButton: UIButton!
    @IBOutlet weak var titleTextField: UITextField!
    @IBOutlet weak var textCountLabel: UILabel!
    
    @IBOutlet weak var contentNumberLabel: UILabel!
    @IBOutlet weak var mainTextView: IQTextView!
    override func viewDidLoad() {
        super.viewDidLoad()
        setNavigationColor(colorState: .black)
        setNavigationBar()
        setUI()
        // Do any additional setup after loading the view.
    }
    
    func setUI() {
        var zP: CGFloat = 1
        for view in shadowViews {
            setShadow(view: view, opacity: bottomShadowOpacity, size: CGSize(width: 0, height: 3), color: UIColor.black, cornerradius: CORNERRADIUS)
            view.layer.zPosition = zP
            zP -= 0.1
        }
        
        setShadow(view: circleButton, opacity: bottomShadowOpacity, size: CGSize(width: 0, height: 3), color: UIColor.black, cornerradius: CORNERRADIUS)
        
        
        titleTextField.delegate = self
    }
    
    func setNavigationBar() {
        let titleButton = UIButton()
        titleButton.setTitle("发布", for: .normal)
        titleButton.setImage(UIImage(named: "icon_address"), for: .normal)
        titleButton.imageEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0)
        self.navigationItem.titleView = titleButton
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "btn_determine"), style: .done, target: self, action: #selector(doneTap))
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "all_return"), style: .done, target: self, action: #selector(returnRootVC))
    }
    
    @objc func returnRootVC() {
        let showView = CustomShowAlertView()
        if !mainTextView.text.isEmpty || !titleTextField.text!.isEmpty {
            showView.show(title: "是否保存为草稿") { (isCancel) in
                if isCancel {
                    CustomShowAlertView().show(title: "操作成功", showTime: 3) {
                        self.navigationController?.dismiss(animated: true, completion: nil)
                    }
                }
            }
        }
    }
    
    @objc func doneTap() {
        let showView = CustomShowAlertView()
        showView.show(title: "发布成功", showTime: 3) {
            self.navigationController?.dismiss(animated: true, completion: nil)
        }
    }
    
    @IBAction func selectContentVideoTap(_ sender: UIGestureRecognizer) {
        
    }
    
    @IBAction func selectCircleTap(_ sender: UIButton) {
    }
    
    
}
